﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TBESTNR
    {
        #region ==BESTNR===========
        public static readonly DependencyProperty BESTNRProperty = DependencyProperty.Register("BESTNR",
            typeof(string), typeof(TBESTNR),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBESTNRChanged));
        public string BESTNR
        {
            get
            {
                return (string)GetValue(BESTNRProperty);
            }
            set
            {
                SetValue(BESTNRProperty, value);
            }
        }
        private static void OnBESTNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TBESTNR;
            if (src != null)
            {
                src.BESTNR = (string)e.NewValue;
            }
        }
        #endregion
        public TBESTNR()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVKKOPF();
            this.DataContext = MV;
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            if(dwMain==null)
            { }
            if (dwMaster == null)
            {
                BESTNR = "";
            }
            else
            {
                BESTNR = dwMaster["BESTNR"].ToString();
            }
        }
        
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
            SResult = TMV.QueryVKKOPF(dwData, -2); 
            MergeData(SResult);
            vwMaster.View.MoveCurrentTo(-1);
        }
    }
}
